#ifndef __WWINDEEF_H
#define __WWINDEEF_H

#if !defined(_WIN32)

	typedef char CHAR;
	typedef CHAR *LPSTR;
	typedef const CHAR *LPCSTR;
	typedef unsigned char UCHAR;

	typedef wchar_t WCHAR;
	typedef WCHAR *LPWSTR;
	typedef const WCHAR *LPCWSTR;

	typedef unsigned short CHARU16;

	typedef unsigned char BYTE;
	typedef unsigned int UINT;
	typedef int INT;
	typedef int BOOL;
	typedef long LONG;
	typedef unsigned long DWORD;
	typedef short SHORT;
	typedef unsigned short WORD;
	typedef unsigned short USHORT;
	typedef long long int LONGLONG;
	typedef unsigned long long int ULONGLONG;

	typedef DWORD   COLORREF;
	typedef DWORD   *LPCOLORREF;

	typedef DWORD ULONG;
	typedef LONG LRESULT;
	typedef LONG HRESULT;
	typedef WORD *LPWORD;
	typedef DWORD *LPDWORD;
	typedef LONG* LPLONG;
	typedef BYTE* PBYTE;
	typedef double DOUBLE;

	typedef void VOID;
	typedef VOID* LPVOID;

	typedef __int64_t LONGLONG;
	typedef __uint64_t ULONGLONG;	
	typedef __uint64_t	QWORD;

	typedef union _LARGE_INTEGER {
		struct {
			DWORD LowPart;
			LONG HighPart;
		};
		struct {
			DWORD LowPart;
			LONG HighPart;
		} u;
		LONGLONG QuadPart;
	} LARGE_INTEGER;	

	typedef struct _GUID{
		
		unsigned long	Data1;
		unsigned short  Data2;
		unsigned short  Data3;
		unsigned char 	Data4[8];
	}GUID;
	typedef GUID 	IID;
	typedef GUID	CLSID;

	typedef DWORD WPARAM;
	typedef DWORD LPARAM;
	
	typedef void* HANDLE;
	typedef void* HWND;
	typedef void* HMODULE;

	typedef DWORD COLORREF;
	
	#ifndef FALSE
		#define FALSE  0
		#define TRUE   1
	#endif

	#ifndef MAX_PATH
		#define MAX_PATH	256
	#endif
	
	#define INFINITE		((DWORD)0xffffffff)
	#define WAIT_OBJECT_0	((DWORD)0x00000000)
	#define WAIT_TIMEOUT	((DWORD)0x00000102)
	
	#define NOVTABLE
	#define CALLBACK
	#define WINAPI
	#define STDAPICALLTYPE
	#define STDMETHODCALLTYPE
	#define __cdecl
	
	#define NEAR
	#define FAR
	
	#define 	WM_USER			100
	#define		WM_TIMER		WM_USER+98
	#define 	WM_QUIT			WM_USER+99
	
	#ifdef __cplusplus
	
		#define EXTERN_C	extern "C"
		#define REFIID 		const IID &
		#define REFCLSID	const IID &
		
		#define interface	struct
		#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
		#define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
		#define PURE		= 0
		#define THIS_		
		#define THIS		void
		#define DECLARE_INTERFACE(iface) interface iface
		#define DECLARE_INTERFACE_(iface,baseiface) interface iface: public baseiface
	
	#else
	
		#define EXTERN_C	extern
		#define REFIID 		const IID *
		#define REFCLSID	const IID *
		
		#define interface 	struct NOVTABLE
		#define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE* method)
		#define STDMETHOD_(type,method) type (STDMETHODCALLTYPE* method)
		#define PURE
		#define THIS_		INTERFACE* This,
		#define THIS		INTERFACE* This
		#define DECLARE_INTERFACE( iface ) typedef interface iface{ \
							struct iface##Vtbl * lpVtbl; \
						} iface;\
						typedef struct iface##Vtbl iface##Vtbl; \
						struct iface##Vtbl
		#define DECLARE_INTERFACE_(iface,baseiface ) DECLARE_INTERFACE( iface )
	
	#endif //_cplusplus
	
	#define REFGUID		REFIID
	
	#ifdef __cplusplus
	
		__inline int InlineIsEqualGUID( REFGUID rguid1,REFGUID rguid2 )
		{
			return (
				((unsigned long*)&rguid1)[0] == ((unsigned long*)&rguid2)[0] &&
				((unsigned long*)&rguid1)[1] == ((unsigned long*)&rguid2)[1] &&
				((unsigned long*)&rguid1)[2] == ((unsigned long*)&rguid2)[2] &&
				((unsigned long*)&rguid1)[3] == ((unsigned long*)&rguid2)[3]);
		}
		
		#include <memory.h>
		
		__inline int IsEqualGUID( REFGUID rguid1,REFGUID rguid2 )
		{
			return !memcmp( &rguid1,&rguid2,sizeof(GUID));
		}
		
		__inline int operator==( REFGUID guidOne,REFGUID guidOther )
		{
			return IsEqualGUID( guidOne,guidOther );
		}
		
		__inline int operator!=( REFGUID guidOne,REFGUID guidOther )
		{
			return !( guidOne == guidOther );
		}
		
		#define IsEqualCLSID	IsEqualGUID
	
	#endif //_cplusplus
	
	#define STDAPI		EXTERN_C HRESULT STDAPICALLTYPE
	#define STDAPI_(type)	EXTERN_C type STDAPICALLTYPE
	
	#define STDMETHODIMP	HRESULT STDMETHODCALLTYPE
	#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
	
	#ifdef INITGUID
		#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8 ) \
			EXTERN_C const GUID name \
				= { l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8 }}
	#else
		#define DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8 ) \
			EXTERN_C const GUID name
	#endif // INITGUID

	#define MoveMemory( d,s,l )	memmove( (d),(s),(l))
	#define CopyMemory( d,s,l )	memcpy( (d),(s),(l))
	#define FillMemory( d,l,f )	memset( (d),(f),(l))
	#define ZeroMemory( d,l )	memset( (d),0,(l))

	#define MAKEFOURCC(ch0, ch1, ch2, ch3)                              \
		((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) |   \
	((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))

	/* MMIO macros */
	#define mmioFOURCC(ch0, ch1, ch2, ch3)  MAKEFOURCC(ch0, ch1, ch2, ch3)
	
	#define BI_RGB		0
	#define BI_BITFIELDS    3

	#define RGB(r,g,b)          ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
	#define GetRValue(rgb)      ((BYTE)(rgb))
	#define GetGValue(rgb)      ((BYTE)(((WORD)(rgb)) >> 8))
	#define GetBValue(rgb)      ((BYTE)((rgb)>>16))
	
	typedef struct tagBITMAPINFOHEADER{
			DWORD      biSize;
			LONG       biWidth;
			LONG       biHeight;
			WORD       biPlanes;
			WORD       biBitCount;
			DWORD      biCompression;
			DWORD      biSizeImage;
			LONG       biXPelsPerMeter;
			LONG       biYPelsPerMeter;
			DWORD      biClrUsed;
			DWORD      biClrImportant;
	} BITMAPINFOHEADER;
	
	typedef struct tagRGBQUAD {
        BYTE    rgbBlue;
        BYTE    rgbGreen;
        BYTE    rgbRed;
        BYTE    rgbReserved;
	} RGBQUAD;
	
	typedef struct tagBITMAPINFO {
		BITMAPINFOHEADER    bmiHeader;
		RGBQUAD             bmiColors[1];
	} BITMAPINFO;

	typedef struct tagPOINT
	{
		LONG  x;
		LONG  y;
	} POINT, *PPOINT;
	
	typedef struct tagRECT
	{
		LONG    left;
		LONG    top;
		LONG    right;
		LONG    bottom;
	} RECT, *PRECT, *LPRECT;
	typedef const RECT* LPCRECT;
	
	typedef struct tagSIZE
	{
		LONG        cx;
		LONG        cy;
	} SIZE, *PSIZE, *LPSIZE;	
	
	#ifndef _WAVEFORMATEX_
	
	#define WAVE_FORMAT_PCM     1
	
	#define _WAVEFORMATEX_
	typedef struct tWAVEFORMATEX
	{
		WORD    wFormatTag;        /* format type */
		WORD    nChannels;         /* number of channels (i.e. mono, stereo...) */
		DWORD   nSamplesPerSec;    /* sample rate */
		DWORD   nAvgBytesPerSec;   /* for buffer estimation */
		WORD    nBlockAlign;       /* block size of data */
		WORD    wBitsPerSample;    /* Number of bits per sample of mono data */
		WORD    cbSize;            /* The count in bytes of the size of
										extra information (after cbSize) */
	} WAVEFORMATEX;
	#endif /* _WAVEFORMATEX_ */

	/* Logical Font */
	#define LF_FACESIZE         32

	typedef struct tagLOGFONTA
	{
		LONG      lfHeight;
		LONG      lfWidth;
		LONG      lfEscapement;
		LONG      lfOrientation;
		LONG      lfWeight;
		BYTE      lfItalic;
		BYTE      lfUnderline;
		BYTE      lfStrikeOut;
		BYTE      lfCharSet;
		BYTE      lfOutPrecision;
		BYTE      lfClipPrecision;
		BYTE      lfQuality;
		BYTE      lfPitchAndFamily;
		CHAR      lfFaceName[LF_FACESIZE];
	} LOGFONTA, *PLOGFONTA, NEAR *NPLOGFONTA, FAR *LPLOGFONTA;
	typedef struct tagLOGFONTW
	{
		LONG      lfHeight;
		LONG      lfWidth;
		LONG      lfEscapement;
		LONG      lfOrientation;
		LONG      lfWeight;
		BYTE      lfItalic;
		BYTE      lfUnderline;
		BYTE      lfStrikeOut;
		BYTE      lfCharSet;
		BYTE      lfOutPrecision;
		BYTE      lfClipPrecision;
		BYTE      lfQuality;
		BYTE      lfPitchAndFamily;
		WCHAR     lfFaceName[LF_FACESIZE];
	} LOGFONTW, *PLOGFONTW, NEAR *NPLOGFONTW, FAR *LPLOGFONTW;
	#ifdef UNICODE
	typedef LOGFONTW LOGFONT;
	typedef PLOGFONTW PLOGFONT;
	typedef NPLOGFONTW NPLOGFONT;
	typedef LPLOGFONTW LPLOGFONT;
	#else
	typedef LOGFONTA LOGFONT;
	typedef PLOGFONTA PLOGFONT;
	typedef NPLOGFONTA NPLOGFONT;
	typedef LPLOGFONTA LPLOGFONT;
	#endif // UNICODE
	
#endif	//_WIN32

#endif